package com.qidian.tcba.admin.api.controller;


import com.qidian.tcba.admin.model.dto.user.UserOrgMsgDTO;
import com.qidian.tcba.admin.model.param.UserOrgMsgParam;
import com.qidian.tcba.admin.service.UserExtendMsgService;
import com.qidian.tcba.utils.result.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 用户扩展信息表 前端控制器
 * </p>
 *
 * @author 冯永龙
 * @since 2021-07-06
 */
@RestController
@RequestMapping("/userExtendMsg")
@Api(tags ="用户扩展信息")
public class UserExtendMsgController {

    @Autowired
    private UserExtendMsgService userExtendMsgService;

    @ApiOperation("获取单位信息")
    @GetMapping("/getUserOrg/{userId}")
    public JsonResult getUserOrgMeg(@PathVariable("userId")int userId){
        UserOrgMsgDTO userOrgMsg = userExtendMsgService.getUserOrgMsg(userId);
        if (userOrgMsg != null){
            return JsonResult.success().data("row",userOrgMsg);
        }else {
            return JsonResult.error().data("row","单位信息未完善");
        }
    }

    @ApiOperation("完善单位信息")
    @PostMapping("/completeOrgMsg")
    public JsonResult completeOrgMsg(@RequestBody UserOrgMsgParam userOrgMsgParam){
        boolean result = userExtendMsgService.completeOrgMsg(userOrgMsgParam);
        if (result){
            return JsonResult.success();
        }else {
            return JsonResult.error();
        }
    }
}

